﻿@model Beauty.Web.Page.PagedList<Beauty.Model.Like>
@using Beauty.Web.Page

@{
   
}

<style>


</style>

@using (Html.BeginForm("PostShare", "Share", FormMethod.Post, new {id="shareform" }))
{
   <ul class="nav nav-pills">
      <li>
        <a href="/like/index">未喜欢</a>
      </li>
      <li  class="active"><a href="/like/liking">正在喜欢</a></li>
      <li><a href="/like/hasliked">已喜欢</a></li>

    </ul>
   
        <table class="table table-bordered table-hover table-condensed text-center">
        <thead>
            <tr>
                <th class="centerandmiddle"></th>
                <th class="hidden"></th>
                <th class="centerandmiddle">商品列表</th>
                <th class="centerandmiddle">喜欢数量</th>
                <th class="centerandmiddle">评论数量</th>
                <th class="centerandmiddle">粉丝数量</th>
                <th class="centerandmiddle">收录数量</th>
                <th class="centerandmiddle">超级主编收录数量</th>
                <th class="centerandmiddle">状态</th>
            </tr>
        </thead>
        <tbody>
            @for (var i = 0; i < Model.Count; i++)
            {
                <tr>
                    <td class="centerandmiddle">@Html.CheckBox(@Model[i].Bady.ID.ToString(), new { id = @Model[i].Bady.ID.ToString() })</td>
                    <td class="hidden">
                        @Html.TextBoxFor(m => m[i].ID)
                        @Html.TextBoxFor(m => m[i].Bady.ID)   
                        @Html.TextBoxFor(m => m[i].Username)   
                    </td>
                  <td class="centerandmiddle" style=" width:190px;"><div class="clearfix"><div class="pull-left"><img src="@Model[i].Bady.ImageUrl" height="60" width="60" style=" height:60px; width:60px;" /></div><div class="pull-left" style="width:120px; padding-left:5px;"> <a href="http://www.meilishuo.com/share/@Model[i].Bady.Twitterid" target="_blank">@Model[i].Bady.Badydescription</a></div></div> </td>
                    <td class="centerandmiddle"> @Model[i].Likenum</td>
                     <td class="centerandmiddle"> @Model[i].Commentnum</td>
                     <td class="centerandmiddle"> @Model[i].Likednum</td>
                     <td class="centerandmiddle"> @Model[i].Recordnum</td>
                     <td class="centerandmiddle"> @Model[i].Supernum</td>
                    <td class="centerandmiddle">  @if (Model[i].Runstatues == 3)
                        {
                            <text>停止</text>
                        }
                        else
                        {
                            <text>正在运行</text>
                        }</td>
                  
                </tr>
            }

        </tbody>

    </table>
    <div class="pagination">

        @Html.Pager(Model)
        <div class="pull-right">
             <input type="button" value="删除" class="btn" id="submitdelete" />
                <input type="button" value="重新开始" class="btn" id="submitstart" />
              <input type="button" value="停止" class="btn" id="submitstop" />
        </div>
    </div>
    

}

 
<script>
   
    $(function () {
        $("ul[class='nav'] li[class!='dropdown']").removeClass();
        $("ul[class='nav'] li:eq(1)").addClass("active");

        $("#savesetting").click(function () {
            $.ajax({
                url: '/like/Usersetting',
                type: 'POST',
                dataType: 'json',
                data: $.toJSON({ likerate: $("#likesetting").val(), recordrate: $("#recordsetting").val(), likedrate: $("#likedsetting").val(), commentrate: $("#commentsetting").val() }),
                contentType: 'application/json; charset=utf-8',
                success: function (data) {

                }
            }).done(function (data) {
                if (data) {
                    ShowMsg("保存成功");
                   
                }
                else {
                    ShowMsg("保存失败");
                }
            });
        })

    
        $("#submitdelete").click(function () {

            ShowConfirmMsg("确定删除吗？", function () {
                var data = new Array();
                var isselect = false;
                $("tr").each(function (index) {
                    var ischeck = $(this).find("td:eq(0)").find("input[type='checkbox']").attr("checked");
                    if (ischeck == "checked") {
                        var ID = $(this).find("td:eq(1)").find("input[name*='ID']").not("input[name*='Bady']").val();

                        var temp = {};

                        temp.ID = ID;
                        data.push(temp);
                        isselect = true;
                    }
                });

                if (isselect) {
                    $.ajax({
                        url: '/like/Deleteliking',
                        type: 'POST',
                        dataType: 'json',
                        data: $.toJSON({ data: data }),
                        contentType: 'application/json; charset=utf-8',
                        success: function (data) {

                        }
                    }).done(function (data) {
                        if (data.Result) {
                            ShowMsg(data.Msg, function () {
                                location.href = location.href;
                            });
                        }
                        else {
                            ShowMsg(data.Msg);
                        }

                    });
                }
                else {
                    ShowMsg("请勾选一行数据");
                }

            })
        })

        $("#submitstop").click(function () {

            ShowConfirmMsg("确定停止吗？", function () {
                var data = new Array();
                var isselect = false;
                $("tr").each(function (index) {
                    var ischeck = $(this).find("td:eq(0)").find("input[type='checkbox']").attr("checked");
                    if (ischeck == "checked") {
                        var ID = $(this).find("td:eq(1)").find("input[name*='ID']").not("input[name*='Bady']").val();

                        var temp = {};

                        temp.ID = ID;
                        data.push(temp);
                        isselect = true;
                    }
                });

                if (isselect) {
                    $.ajax({
                        url: '/like/Stopliking',
                        type: 'POST',
                        dataType: 'json',
                        data: $.toJSON({ data: data }),
                        contentType: 'application/json; charset=utf-8',
                        success: function (data) {

                        }
                    }).done(function (data) {
                        if (data.Result) {
                            ShowMsg(data.Msg, function () {
                                location.href = location.href;
                            });
                        }
                        else {
                            ShowMsg(data.Msg);
                        }

                    });
                }
                else {
                    ShowMsg("请勾选一行数据");
                }

            })
        })

        $("#submitstart").click(function () {

            ShowConfirmMsg("确定重新开始吗？", function () {
                var data = new Array();
                var isselect = false;
                $("tr").each(function (index) {
                    var ischeck = $(this).find("td:eq(0)").find("input[type='checkbox']").attr("checked");
                    if (ischeck == "checked") {
                        var ID = $(this).find("td:eq(1)").find("input[name*='ID']").not("input[name*='Bady']").val();

                        var temp = {};

                        temp.ID = ID;
                        data.push(temp);
                        isselect = true;
                    }
                });

                if (isselect) {
                    $.ajax({
                        url: '/like/ReStartLike',
                        type: 'POST',
                        dataType: 'json',
                        data: $.toJSON({ data: data }),
                        contentType: 'application/json; charset=utf-8',
                        success: function (data) {

                        }
                    }).done(function (data) {
                        if (data.Result) {
                            ShowMsg(data.Msg, function () {
                                location.href = location.href;
                            });
                        }
                        else {
                            ShowMsg(data.Msg);
                        }

                    });
                }
                else {
                    ShowMsg("请勾选一行数据");
                }

            })
        })
    })



</script>